<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('我的资产列表')" />
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="ibox-title">
                <h5>我的资产列表</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" >
                    <i class="fa fa-plus"></i> 申请借用
                </a>
                <a class="btn btn-success" onclick="assetsSearch()" >
                    <i class="fa fa-edit"></i> 资产查询
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
      </div>
    </div>
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/ajax/libs/flot/jquery.flot.js}"></script>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: sparkline-js" />
    <script th:inline="javascript">
        var prefix = ctx + "assets/presion";
        var assetsTypeDatas = [[${@dict.getType('assets_type')}]];
        var assetsStatusDatas = [[${@dict.getType('assets_status')}]];
        var userid = [[${userid}]];

        function assetsSearch() {
            $.modal.open('资产查询', prefix + "/assetsSearch");
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: ctx + "assets/repairs/add/{id}",
                modalName: "我的资产",
                createUrl: "assets/borrow/add/"+userid,
                sortName: "createTime",
                sortOrder: "desc",
                showSearch: false,
                showPageGo: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                pagination:false,
                queryParams: {
                    userId: userid
                },
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '资产编号',
                        visible: true
                    },
                    {
                        field: 'assetsName',
                        title: '资产名称'
                    },
                    {
                        field: 'assetsType',
                        title: '资产类别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(assetsTypeDatas, value);
                        }
                    },
                    {
                        field: 'assetsModel',
                        title: '规格型号'
                    },
                    {
                        field: 'assetsSn',
                        title: 'SN号'
                    },
                    {
                        field: 'createTime',
                        title: '领用时间'
                    },
                    {
                        field: 'createTime',
                        title: '归还时间'
                    },
                    {
                        field: 'assetsStatus',
                        title: '设备状态',
                        formatter: function(value, row, index) {
                            if(value == 3){
                                var actions = [];
                                actions.push('<span class="label label-warning">'+$.table.selectDictLabel(assetsStatusDatas, value)+'</span> ');
                                return actions.join('');

                            }else{
                                return $.table.selectDictLabel(assetsStatusDatas, value);
                            }

                        }
                    },
                    {
                        title: '操作',
                        align: 'left',
                        formatter: function(value, row, index) {
                            if(row.assetsStatus != 3 ) {
                                var actions = [];
                                actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-remove"></i>报修</a>');
                                return actions.join('');
                            }
                        }
                    }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>
